package com.cryrabbit.yyystitp.ui.activities;

import android.app.Application;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;

import com.cryrabbit.yyystitp.MyApplication;
import com.cryrabbit.yyystitp.R;
import com.cryrabbit.yyystitp.net.PushHttpMethods;
import com.cryrabbit.yyystitp.ui.iviews.Iview;
import com.cryrabbit.yyystitp.ui.presenters.SendPresenter;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import rx.Subscriber;

/**
 * Created by CryRabbit on 2016/9/17.
 */

public class SendMessageActivity extends AppCompatActivity implements Iview{
    //@BindView(R.id.ac_send_et_title)
    EditText title;
    String user="yyy";
    String city;
    String kind;
    String pay=null;
    String length;
    String content;
    @BindView(R.id.money)
    EditText money;
    @BindView(R.id.time)
    EditText time;
    @BindView(R.id.introduction)
    EditText introduction;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sendmessage);
        ButterKnife.bind(this);

    }

    @OnClick(R.id.ac_send_button)
    void send(){
        String content=introduction.getText().toString();
        city= MyApplication.City;
        pay=money.getText().toString().trim();
        length=time.getText().toString().trim();
        content=introduction.getText().toString().trim();
        //根据ID找到RadioGroup实例
        RadioGroup group = (RadioGroup)this.findViewById(R.id.rg);
        //绑定一个匿名监听器
        group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                                             @Override
                                             public void onCheckedChanged(RadioGroup radioGroup, int i) {
                                                 int radioButtonId = radioGroup.getCheckedRadioButtonId();
                                                 //根据ID获取RadioButton的实例
                                                 RadioButton rb = (RadioButton)SendMessageActivity.this.findViewById(radioButtonId);
                                                 kind= rb.getText().toString();

                                             }
                                         }

        );
        PushHttpMethods pushHttpMethods=new PushHttpMethods();
        pushHttpMethods.getNet(new Subscriber<String>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(String s) {

            }
        },"yyy","杨思明",content,city,kind,pay,length);

    }


    @Override
    public void getResult(String s) {
        Toast.makeText(SendMessageActivity.this,s,Toast.LENGTH_LONG).show();
    }
}
